###
 # @Description: 
 # @Version: 2.0
 # @Autor: gang
 # @Date: 2020-09-17 17:30:23
 # @LastEditors: gang
 # @LastEditTime: 2020-10-16 18:21:29
 # 0    0    24    *    *    /usr/bin/curl -X POST -H "flag:tm"  "http://xxxx.com/csv/outdata"  > /dev/null
### 
#!/bin/bash
#生成csv数据
gender=`/usr/bin/curl  -X POST -H "flag:tm"  "http://xxxx.com/csv/outdata"`
#ftp地址
SFTP_ADDR=sftp://xxx.com:22
#用户名
USER="xxx"
#密码
PASSWORD="0k5bhUTrDs"
#待上传文件根目录
LOCAL_CLIENT_DIR=/home/outcsv
#SFTP目录
CUSTOMER_SEVER_DIR=/u_jfgj/Test

PRODTCT_SEVER_DIR=/u_jfgj/DailyFiles
#待上传文件名
FILENAME=$(date -d "yesterday" +%Y%m%d).csv
if [ $gender -eq 1 ]
then
    # echo ${FILENAME}
    if [ -e ${LOCAL_CLIENT_DIR}\/${FILENAME} ]
    then
        FILE=${FILENAME}
        lftp -u ${USER},${PASSWORD} ${SFTP_ADDR} <<EOF
cd ${PRODTCT_SEVER_DIR}/
lcd ${LOCAL_CLIENT_DIR}
put ${FILE}
by
EOF
    else
        echo "文件不存在"
    fi
else
    echo "genner csv error"
fi

